package preferencePackage;

import mapPackage.IRoute;
import mapPackage.ITronconNonModifiable;
import mapPackage.IVilleNonModifiable;
import mapPackage.MapException;
import mapPackage.typeRoute.STypeRoute;
import xmlPackage.Carte;

public class Pref_TypeRouteVoulue extends Preference 
{
	private STypeRoute type;
	
	public Pref_TypeRouteVoulue(int classement, boolean positif , STypeRoute type) 
	{
		super(classement, positif);
		this.type = type;
	}

	public float evaluerDestination(IVilleNonModifiable villeDepart , ITronconNonModifiable troncon)
	{
		float score = 0 ;
		try 
		{
			IRoute route = Carte.GetInstance().getRoute( troncon.getRoute() );
			
			

			
			if(positif)
			{
			if( route.getType().equals(type) )score = 0;
			else score = 1;
			}
			else
			{
			if( route.getType().equals(type) )score = 1;
			else score = 0;
			}
			
			
			return score * classement;
		}
		catch (MapException e) {e.printStackTrace();}
		return 1;
	}	
}
